﻿using System.Windows;
using System.Windows.Controls;
using RIA.ServicesLibrary.Web.Models;

namespace RIA.NTiersApp.Views.PruductUI
{
    public partial class ProductDetailsWindow : ChildWindow
    {
        public ProductDetailsWindow ()
        {
            InitializeComponent ();

            vm = this.DataContext as RIA.ViewModel.ProductDetailsViewModel;
            vm.AddNewProduct ();
        }
        RIA.ViewModel.ProductDetailsViewModel vm = null;
        public ProductDetailsWindow ( ProductSummary productSummary )
        {
            InitializeComponent ();
            // Logic to load product data corresponding to
            // the passed-in productSummary object can go here
            //vm = new ViewModel.ProductDetailsViewModel ();
            //this.DataContext = vm;
            LoadData ( productSummary );
        }

      
        private void LoadData (ProductSummary ps)
        {
            vm = this.DataContext  as RIA.ViewModel.ProductDetailsViewModel;
            vm.LoadProductExecute (ps.ID);
        }

        private void OKButton_Click ( object sender, RoutedEventArgs e )
        {
            
            //this.DialogResult = true;
        }

        private void CancelButton_Click ( object sender, RoutedEventArgs e )
        {
            this.DialogResult = false;
        }

      
    }
}

